package com.bifang.module.file.gateway.controller;

import com.bifang.module.file.common.vo.fileFieldClass.FileFieldClassBatchVO;
import com.bifang.module.file.core.biz.FileFieldClassIntegration;
import com.bifang.module.file.common.vo.fileFieldClass.FileFieldClassVO;
import com.bifang.module.file.common.vo.fileFieldClass.FileFieldClassKeyVO;
import com.bifang.module.file.common.vo.fileFieldClass.FileFieldClassQueryVO;
import com.github.pagehelper.PageInfo;
import com.bifang.engine.assistant.core.domain.AppResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import com.bifang.engine.protect.core.annotation.Idempotent;
import org.springframework.validation.annotation.Validated;
import com.bifang.assistant.common.constants.Validators;

/**
 * 文件元数据字段分类表网关
 *
 * @author xyh
 * @since 2023-03-16
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "文件元数据字段分类表", description = "文件元数据字段分类表")
public class FileFieldClassController {

    @Autowired
    public FileFieldClassIntegration fileFieldClassIntegration;

    @Operation(summary = "文件元数据字段分类表分页查询",description = "文件元数据字段分类表分页查询")
    @PostMapping(value = "/fileFieldClass0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileFieldClassVO>> getList(@RequestBody @Validated FileFieldClassQueryVO vo) {
        return AppResponse.successData(fileFieldClassIntegration.getList(vo));
    }


    @Operation(summary = "文件元数据字段分类表根据主键查询详情",description = "文件元数据字段分类表根据主键查询详情")
    @PostMapping(value = "/fileFieldClass0002", produces = "application/json;charset=UTF-8")
    public AppResponse<FileFieldClassVO> getById(@RequestBody @Validated FileFieldClassKeyVO vo) {
        return AppResponse.successData(fileFieldClassIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件元数据字段分类表新增",description = "文件元数据字段分类表新增")
    @PostMapping(value = "/fileFieldClass0004", produces = "application/json;charset=UTF-8")
    public AppResponse<FileFieldClassVO> add(@RequestBody @Validated(value = {Validators.Add.class}) FileFieldClassVO vo) {
        return AppResponse.successData(fileFieldClassIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件元数据字段分类表修改",description = "文件元数据字段分类表修改")
    @PostMapping(value = "/fileFieldClass0005", produces = "application/json;charset=UTF-8")
    public AppResponse<FileFieldClassVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) FileFieldClassVO vo) {
        return AppResponse.successData(fileFieldClassIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件元数据字段分类表删除",description = "文件元数据字段分类表删除")
    @PostMapping(value = "/fileFieldClass0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated FileFieldClassKeyVO vo) {
        fileFieldClassIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件元数据字段分类批量新增",description = "文件元数据字段分类批量新增")
    @PostMapping(value = "/fileFieldClass0007", produces = "application/json;charset=UTF-8")
    public AppResponse addBatch(@RequestBody @Validated(value = {Validators.Add.class}) FileFieldClassBatchVO vo) {
        fileFieldClassIntegration.addBatch(vo);
        return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "文件元数据字段分类批量删除",description = "文件元数据字段分类批量删除")
    @PostMapping(value = "/fileFieldClass0008", produces = "application/json;charset=UTF-8")
    public AppResponse delBatch(@RequestBody @Validated(value = {Validators.BatchDel.class}) FileFieldClassBatchVO vo) {
        fileFieldClassIntegration.delBatch(vo);
        return AppResponse.success();
    }


    @Operation(summary = "文件元数据字段分类已关联查询",description = "文件元数据字段分类已关联查询")
    @PostMapping(value = "/fileFieldClass0009", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<FileFieldClassVO>> getListByClass(@RequestBody @Validated FileFieldClassQueryVO vo) {
        return AppResponse.successData(fileFieldClassIntegration.getListByClass(vo));
    }
}
